namespace Guia.Core
{
    using System;
    using System.Diagnostics.Contracts;
    using System.Threading;

    /// <summary>
    /// Provides some functionality to hold on the program-execution for a given time.
    /// </summary>
    public static class Delay
    {
        /// <summary>
        /// Causes a delay with the given amount of seconds.
        /// </summary>
        /// <param name="seconds">The amount of seconds to hold on the program execution.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if seconds not > 0</exception>
        public static void ForSeconds(double seconds)
        {
            Contract.Requires<ArgumentOutOfRangeException>(seconds > 0);
            int milliseconds = (int)(seconds * 1000);
            ForMilliseconds(milliseconds);
        }

        /// <summary>
        /// Causes a delay with the given amount of milliseconds.
        /// </summary>
        /// <param name="milliseconds">The amount of milliseconds to hold on the program execution.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if milliseconds not > 0</exception>
        public static void ForMilliseconds(int milliseconds)
        {
            Contract.Requires<ArgumentOutOfRangeException>(milliseconds > 0);
            Thread.Sleep(milliseconds);
        }
    }
}